package com.store.webstore.controller;

import com.store.webstore.entity.MessageResult;
import com.store.webstore.entity.User;
import com.store.webstore.service.RegistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/user")
public class RegistController {
    @Autowired
    private RegistService registService;

    public MessageResult regist(User user){
        MessageResult result = new MessageResult();
        try {
            registService.save(user);
            result.setMessage("注册成功");
            result.setSuccess(true);
        }catch (Exception e){
            result.setErrorMessage("注册失败");
            e.printStackTrace();
        }
        return result;
    }
}
